package com.bianguo.android.baidumapdemo.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;

import com.bianguo.android.baidumapdemo.R;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * Created by Administrator on 2018/6/6.
 */

public class BezierGoodsAdapter extends BaseRecyclerAdapter<String> {

    public BezierGoodsAdapter(Context mContext, ArrayList<String> list) {
        super(mContext, list);
    }

    @Override
    public BaseViewHolder createHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item_bezier_goods_layout, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void bindHolder(BaseViewHolder holder, int position) {
        final ViewHolder viewHolder = (ViewHolder) holder;
        String s = list.get(position);
        viewHolder.nameTv.setText(s);
        viewHolder.reduceIb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onClickItemListener != null) {
                    onClickItemListener.onClickItem(BezierGoodsAdapter.this, view, viewHolder.getAdapterPosition());
                }
            }
        });
        viewHolder.addIb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onClickItemListener != null) {
                    onClickItemListener.onClickItem(BezierGoodsAdapter.this, view, viewHolder.getAdapterPosition());
                }
            }
        });
    }

    public static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.item_bezier_goods_name)
        TextView nameTv;
        @BindView(R.id.item_bezier_goods_reduce)
        ImageButton reduceIb;
        @BindView(R.id.item_bezier_goods_count)
        TextView countTv;
        @BindView(R.id.item_bezier_goods_add)
        ImageButton addIb;

        public ViewHolder(View itemView) {
            super(itemView);
        }
    }
}
